/**
 * 钱包页面
 * author wim
 */
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:panda/base/Constant.dart';
import 'package:panda/goods/UserUpdateGoodsList.dart';
import 'package:panda/set/BalanceRecord.dart';
import 'package:panda/set/DrawMoney.dart';
import 'package:panda/set/FillAuthCode.dart';
import 'package:panda/set/MyBank.dart';
import 'package:panda/set/Recharge.dart';
import 'package:panda/set/VIPTest.dart';

class MyWalletPage extends StatefulWidget {
  MyWalletPage({Key key}) : super(key: key);

  @override
  _MyWalletPageState createState() => _MyWalletPageState();
}

class _MyWalletPageState extends State<MyWalletPage> {
  List<Color> colors = new List();
  @override
  void initState() {
    // TODO: implement initState
    super.initState();
    colors..add(Colors.red[900])..add(Colors.green[400]);
  }

  @override
  Widget build(BuildContext context) {
    return new Scaffold(
      body: AnnotatedRegion<SystemUiOverlayStyle>(
        value: SystemUiOverlayStyle.light,
        child: new Stack(
          children: <Widget>[
            Container(
                width: double.infinity,
                height: ScreenUtil.getInstance().setHeight(DP_350 + DP_30),
                padding: EdgeInsets.fromLTRB(
                    ScreenUtil.getInstance().setWidth(DP_30),
                    kTextTabBarHeight,
                    ScreenUtil.getInstance().setWidth(DP_30),
                    0),
                decoration: BoxDecoration(
                  image: DecorationImage(
                      image: AssetImage('images/bg_wallet.png'),
                      fit: BoxFit.fill),
                ),
                child: Column(
                  children: <Widget>[
                    Row(
                      mainAxisAlignment: MainAxisAlignment.start,
                      crossAxisAlignment: CrossAxisAlignment.center,
                      children: <Widget>[
                        GestureDetector(
                          child: Icon(Icons.arrow_back_ios,
                              color: white,
                              size: ScreenUtil.getInstance().setHeight(DP_40)),
                          onTap: () {
                            Navigator.of(context).pop();
                          },
                        ),
                        Expanded(
                          child: Text(''),
                        ),
                        Text('我的钱包',
                            style: TextStyle(
                                color: white,
                                fontSize: ScreenUtil.getInstance()
                                    .setSp(BIG_FONT_SIZE))),
                        Expanded(
                          child: Text(''),
                        ),
                        Offstage(
                          offstage: true,
                          child: Icon(Icons.arrow_back_ios,
                              color: white,
                              size: ScreenUtil.getInstance().setHeight(DP_40)),
                        )
                      ],
                    ),
                  ],
                )),
            new Column(
              children: <Widget>[
                Container(
                  width: double.infinity,
                  padding:
                      EdgeInsets.all(ScreenUtil.getInstance().setHeight(DP_30)),
                  height: ScreenUtil.getInstance().setHeight(DP_250),
                  margin: EdgeInsets.fromLTRB(
                      ScreenUtil.getInstance().setHeight(DP_20),
                      ScreenUtil.getInstance().setHeight(DP_150),
                      ScreenUtil.getInstance().setHeight(DP_20),
                      0),
                  decoration: BoxDecoration(
                    image: DecorationImage(
                        image: AssetImage('images/bg_money.png'),
                        fit: BoxFit.fill),
                  ),
                  child: new Column(
                    crossAxisAlignment: CrossAxisAlignment.start,
                    children: <Widget>[
                      Text('我的余额(元)',
                          style: TextStyle(
                              color: black_99,
                              fontSize: ScreenUtil.getInstance()
                                  .setSp(SMALL_FONT_SIZE))),
                      Container(
                        height: ScreenUtil.getInstance().setHeight(DP_8),
                      ),
                      Row(
                        children: <Widget>[
                          Text('7948.59',
                              style: TextStyle(
                                  color: mainColor,
                                  fontSize: ScreenUtil.getInstance()
                                      .setSp(BIG_FONT_SIZE * 2 - 10))),
                          Expanded(
                            child: Text(''),
                          ),
                          new Container(
                            height: ScreenUtil.getInstance().setHeight(DP_40),
                            decoration: new BoxDecoration(
                                border:
                                    Border.all(color: Colors.black45, width: 1),
                                borderRadius: BorderRadius.circular(
                                    ScreenUtil.getInstance().setHeight(DP_40))),
                            padding: EdgeInsets.fromLTRB(0.0, 0.0, 0.0, 0.0),
                            child: new FlatButton(
                              child: new Padding(
                                padding: EdgeInsets.all(0.0),
                                child: new Text(
                                  "余额明细",
                                  style: new TextStyle(
                                      color: Colors.black45,
                                      fontSize: ScreenUtil.getInstance()
                                          .setSp(MINI_FONT_SIZE)),
                                ),
                              ),
                              onPressed: () {},
                            ),
                          )
                        ],
                      ),
                      Expanded(
                        child: Text(''),
                      ),
                      Row(
                        children: <Widget>[
                          Expanded(
                            child: Text(''),
                          ),
                          GestureDetector(
                            onTap: () {
                              Navigator.of(context).push(
                                  new MaterialPageRoute(builder: (context) {
                                return new UserUpdateListPage();
                              }));
                            },
                            child: Text(
                              '充值',
                              style: TextStyle(
                                  color: black,
                                  fontSize: ScreenUtil.getInstance()
                                      .setSp(NORMAL_FONT_SIZE)),
                            ),
                          ),
                          Expanded(
                            child: Text(''),
                          ),
                          Expanded(
                            child: Text(''),
                          ),
                          GestureDetector(
                            onTap: () {
                              Navigator.of(context).push(
                                  new MaterialPageRoute(builder: (context) {
                                return new DrawMoneyPage(total: "1.0",);
                              }));
                            },
                            child: Text(
                              '提现',
                              style: TextStyle(
                                  color: black,
                                  fontSize: ScreenUtil.getInstance()
                                      .setSp(NORMAL_FONT_SIZE)),
                            ),
                          ),
                          Expanded(
                            child: Text(''),
                          ),
                        ],
                      )
                    ],
                  ),
                ),
                Padding(
                  padding: EdgeInsets.fromLTRB(
                      ScreenUtil.getInstance().setHeight(DP_20),
                      ScreenUtil.getInstance().setHeight(DP_50),
                      ScreenUtil.getInstance().setHeight(DP_20),
                      ScreenUtil.getInstance().setHeight(DP_30)),
                  child: Row(
                    crossAxisAlignment: CrossAxisAlignment.center,
                    children: <Widget>[
                      Expanded(
                        child: Text(
                          '会员储值卡',
                          style: TextStyle(
                              color: black,
                              fontSize: ScreenUtil.getInstance()
                                  .setSp(BIG_FONT_SIZE)),
                        ),
                      ),
                      GestureDetector(
                        child: Container(
                          decoration: BoxDecoration(
                              borderRadius: BorderRadius.circular(
                                  ScreenUtil.getInstance().setHeight(DP_20)),
                              color: grey),
                          padding: EdgeInsets.fromLTRB(
                              ScreenUtil.getInstance().setHeight(DP_20),
                              ScreenUtil.getInstance().setWidth(DP_8),
                              ScreenUtil.getInstance().setHeight(DP_20),
                              ScreenUtil.getInstance().setWidth(DP_8)),
                          child: Text(
                            '全部',
                            style: TextStyle(
                                fontSize: ScreenUtil.getInstance()
                                    .setSp(SMALL_FONT_SIZE),
                                color: Colors.black87),
                          ),
                        ),
                        onTap: () {
                          Navigator.of(context)
                              .push(new MaterialPageRoute(builder: (context) {
                            return new MyBankPage();
                          }));
                        },
                      )
                    ],
                  ),
                ),
                Expanded(
                  flex: 1,
                  child: ListView.builder(
                    scrollDirection: Axis.horizontal,
                    itemBuilder: (BuildContext context, int index) {
                      return Container(
                        padding: EdgeInsets.all(
                            ScreenUtil.getInstance().setHeight(DP_20)),
                        margin: EdgeInsets.fromLTRB(
                            ScreenUtil.getInstance().setHeight(DP_20),
                            0,
                            index == colors.length - 1
                                ? ScreenUtil.getInstance().setHeight(DP_20)
                                : 0,
                            0),
                        width: MediaQuery.of(context).size.width / 2,
                        decoration: BoxDecoration(
                            borderRadius: BorderRadius.circular(15),
                            color: colors[index]),
                        child: Column(
                          crossAxisAlignment: CrossAxisAlignment.end,
                          children: <Widget>[
                            Row(
                              children: <Widget>[
                                ClipOval(
                                    child: Container(
                                  padding: EdgeInsets.all(
                                      ScreenUtil.getInstance()
                                          .setHeight(DP_10)),
                                  color: white,
                                  child: Image.asset(
                                    "images/icon_card.png",
                                    scale: 1.3,
                                  ),
                                )),
                                Container(
                                  width: 10,
                                ),
                                Expanded(
                                  child: Column(
                                    crossAxisAlignment:
                                        CrossAxisAlignment.start,
                                    mainAxisAlignment: MainAxisAlignment.start,
                                    children: <Widget>[
                                      Text(
                                        '中国工商银行',
                                        style: TextStyle(
                                            color: white,
                                            fontSize: ScreenUtil.getInstance()
                                                .setSp(SMALL_FONT_SIZE)),
                                      ),
                                      Container(
                                        height: 4,
                                      ),
                                      Text(
                                        '储蓄卡',
                                        style: TextStyle(
                                            color: white,
                                            fontSize: ScreenUtil.getInstance()
                                                .setSp(MINI_FONT_SIZE)),
                                      ),
                                    ],
                                  ),
                                ),
                              ],
                            ),
                            Expanded(
                              child: Text(''),
                            ),
                            Text(
                              '**** **** **** 9425',
                              style: TextStyle(
                                  color: white,
                                  fontSize: ScreenUtil.getInstance()
                                      .setSp(MINI_FONT_SIZE)),
                            ),
                          ],
                        ),
                      );
                    },
                    itemCount: 2,
                  ),
                ),
                Padding(
                  padding: EdgeInsets.fromLTRB(
                      ScreenUtil.getInstance().setHeight(DP_20),
                      ScreenUtil.getInstance().setHeight(DP_30),
                      ScreenUtil.getInstance().setHeight(DP_20),
                      ScreenUtil.getInstance().setHeight(DP_30)),
                  child: Row(
                    crossAxisAlignment: CrossAxisAlignment.center,
                    children: <Widget>[
                      Expanded(
                        child: Text(
                          '余额明细',
                          style: TextStyle(
                              color: black,
                              fontSize: ScreenUtil.getInstance()
                                  .setSp(BIG_FONT_SIZE)),
                        ),
                      ),
                      GestureDetector(
                        onTap: () {
                          Navigator.of(context)
                              .push(new MaterialPageRoute(builder: (context) {
                            return new BalanceRecordPage();
                          }));
                        },
                        child: Container(
                          decoration: BoxDecoration(
                              borderRadius: BorderRadius.circular(
                                  ScreenUtil.getInstance().setHeight(DP_20)),
                              color: grey),
                          padding: EdgeInsets.fromLTRB(
                              ScreenUtil.getInstance().setHeight(DP_20),
                              ScreenUtil.getInstance().setWidth(DP_8),
                              ScreenUtil.getInstance().setHeight(DP_20),
                              ScreenUtil.getInstance().setWidth(DP_8)),
                          child: Text(
                            '全部',
                            style: TextStyle(
                                fontSize: ScreenUtil.getInstance()
                                    .setSp(SMALL_FONT_SIZE),
                                color: Colors.black87),
                          ),
                        ),
                      )
                    ],
                  ),
                ),
                Expanded(
                  flex: 3,
                  child: Container(
                    padding: EdgeInsets.fromLTRB(
                        ScreenUtil.getInstance().setHeight(DP_15),
                        0,
                        ScreenUtil.getInstance().setHeight(DP_15),
                        ScreenUtil.getInstance().setHeight(0)),
                    margin: EdgeInsets.fromLTRB(
                        ScreenUtil.getInstance().setHeight(DP_20),
                        0,
                        ScreenUtil.getInstance().setHeight(DP_20),
                        ScreenUtil.getInstance().setHeight(DP_60)),
                    decoration: BoxDecoration(
                        color: white, borderRadius: BorderRadius.circular(15)),
                    child: ListView.separated(
                       separatorBuilder: (BuildContext context, int index) {
                      return Container(
                        color: f0Color,
                        margin: EdgeInsets.fromLTRB(ScreenUtil.getInstance().setHeight(DP_100),0,0,0),
                        height: 1,
                      );
                    },
                      padding: EdgeInsets.only(top: 0),
                      itemBuilder: (BuildContext context, int index) {
                        return Container(
                          padding: EdgeInsets.fromLTRB(
                              ScreenUtil.getInstance().setHeight(DP_10),
                              ScreenUtil.getInstance().setHeight(DP_20),
                              ScreenUtil.getInstance().setHeight(DP_10),
                              ScreenUtil.getInstance().setHeight(DP_20)),
                          child: Row(
                            children: <Widget>[
                              Image.asset(
                                "images/icon_recharge.png",
                                scale: 1.3,
                              ),
                              Container(
                                width: 10,
                              ),
                              Expanded(
                                child: Column(
                                  crossAxisAlignment: CrossAxisAlignment.start,
                                  mainAxisAlignment: MainAxisAlignment.start,
                                  children: <Widget>[
                                    Text(
                                      '购物返利',
                                      style: TextStyle(
                                          color: black,
                                          fontSize: ScreenUtil.getInstance()
                                              .setSp(NORMAL_FONT_SIZE)),
                                    ),
                                    Container(
                                      height: 5,
                                    ),
                                    Text(
                                      '2020-01-08 12:12',
                                      style: TextStyle(
                                          color: black_99,
                                          fontSize: ScreenUtil.getInstance()
                                              .setSp(SMALL_FONT_SIZE)),
                                    ),
                                  ],
                                ),
                              ),
                              Column(
                                crossAxisAlignment: CrossAxisAlignment.end,
                                mainAxisAlignment: MainAxisAlignment.end,
                                children: <Widget>[
                                  Text(
                                    '+2789.99',
                                    style: TextStyle(
                                        color: mainColor,
                                        fontSize: ScreenUtil.getInstance()
                                            .setSp(NORMAL_FONT_SIZE)),
                                  ),
                                  Container(
                                    height: 5,
                                  ),
                                  Text(
                                    '...',
                                    style: TextStyle(
                                        color: black_99,
                                        fontWeight: FontWeight.w900,
                                        letterSpacing: 4,
                                        fontSize: ScreenUtil.getInstance()
                                            .setSp(SMALL_FONT_SIZE)),
                                  ),
                                ],
                              )
                            ],
                          ),
                        );
                      },
                      itemCount: 5,
                    ),
                  ),
                ),
              ],
            )
          ],
        ),
      ),
    );
  }
}
